<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                    	<input type="hidden" name="category" value="A69CAECBF07143D58471104829527B74" />
                        <div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>名称：</label>
                            </span>
                            <div class="col-sm-8">
                                <input id="name" name="name" th:value="${info?.name}" class="form-control" type="text" maxlength="100">
                            </div>
                        </div>
                        <div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>英文名称：</label>
                            </span>
                            <div class="col-sm-8">
                                <input id="appName" name="appName" th:value="${info?.appName}" class="form-control" type="text" maxlength="100">
                            </div>
                        </div>
                        <div class="form-group">
                         	<span class="col-sm-3 control-label">
                        		<label style="color:red">*</label>
								<label>所属分类：</label>
							</span>
							<div class="col-lg-8 col-sm-8 col-xs-8">
								 <select  id="groupType" name="groupType" class="form-control" title="类型"> </select>
                 				 <input id="groupTypeValue" th:value="${info?.groupType}" type="hidden">
							</div> 
						</div>
						<div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>视频源：</label>
                            </span>
                            <div class="col-sm-8">
                                <input id="fetchUrl" name="fetchUrl" th:value="${info?.fetchUrl}" class="form-control" type="text" maxlength="3000">
                            </div>
                        </div> 
                        <div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>推送路径：</label>
                            </span>
                            <div class="col-sm-8">
                                <input id="pushUrl" name="pushUrl" th:value="${info?.pushUrl}" class="form-control" type="text" maxlength="3000">
                            </div>
                        </div> 
                        <div class="form-group">
                            <span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>排序：</label>
                            </span>
                            <div class="col-sm-8">
                                <input id="sort" name="sort" th:value="${info?.sort}" class="form-control" type="number" >
                            </div>
                        </div>
                         <div class="form-group">
                         	<span class="col-sm-3 control-label">
	                            <label style="color:red">*</label>
	                            <label>视频源图片：</label>
                            </span>
                         	<div class="col-sm-8">
		                        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="selectImg();" >
		                            <i class="fa fa-chain"></i>选择视频源图片
		                        </button> 
		                        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" id="test1" >
		                            <i class="fa fa-chain"></i>上传本地图片
		                        </button> 
		                        <div style="padding-top: 10px;"></div>
		                         <img width="120px" height="120px" class="layui-upload-img" id="demo2">  
								 <div style="padding-top: 10px;"></div>
								 <input readonly type="text" id="videoImg" name="videoImg" th:value="${info?.videoImg}" class="form-control" >
							 </div>
						</div>
                        <div class="form-group">
                            <div align="center"> 
<!--                            <a class="btn btn-primary btn-sm " onclick="goBack()"><i class="fa fa-arrow-circle-left">返回</i></a> -->
		                        <button type="submit" class="btn btn-primary">提交</button>
	                        </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/js/layui.js"></script>
<script type="text/javascript" src="/js/video/add.js"></script>
<script type="text/javascript">
layui.use('upload', function () {
    var upload = layui.upload;
    //执行实例
    var uploadInst = upload.render({
        elem: '#test1', //绑定元素
        auto:false, 
        acceptMime: 'image/*',
        size: 1000,
        multiple:false,
        number:1,
        accept: 'images',
        choose: function(obj){  
            //将每次选择的文件追加到文件队列 
            files = obj.pushFile();  
            //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
            obj.preview(function(index, file, result){
            	dealImage(result,50,50, useImg); 
           });
        }
    });
});
//新增
function selectImg(url) {
	var url = $("#fetchUrl").val();
	if(!url){
		layer.msg("请输入视频源");
		return false;
	}
    
    var idex = layer.open({
        type : 2,
        title : '增加',
        maxmin : true,
        shadeClose : false, // 点击遮罩关闭层
        btn: ['确定','关闭'],
        area : [ '800px', '520px' ],
        yes: function(index){
            //当点击‘确定’按钮的时候，获取弹出层返回的值
            var res = window["layui-layer-iframe" + index].callbackdata();
            //打印返回的值，看是否有我们想返回的值。
            if(res){ 
            	useImg(res);
            }else{
            	layer.msg("没有获取到图片，请重新获取");
            }
            //最后关闭弹出层
            layer.close(index);
       },
//             success:function (layero,index) {
//                 layer.full(index);
//             },
       content : prefix + '/viewImg?url='+url
   });
}

//然后一压 再打个桩看下长度 方法名随便起怎么舒服怎么来
function useImg(base64) { 
	$('#demo2').attr('src', base64); //图片链接（base64） 
  	$('#videoImg').val(base64);  
}
</script>
</body>
</html>
